package com.anli02.controller;


import com.anli02.entity.pojo.OnlineMusic;
import com.anli02.entity.vo.R;
import com.anli02.service.IOnlineMusicService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.math.BigDecimal;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2024-10-08
 */
@RestController
@RequestMapping("/online-music")
@ApiOperation(value = "音乐上传")
public class OnlineMusicController {
    @Autowired
    private IOnlineMusicService onlineMusicService;

    @ApiOperation("音乐上传")
    @GetMapping("/upload")
    public R upload(  @RequestParam("file") MultipartFile file,
                      @RequestParam("musicName") String musicName,
                      @RequestParam(value = "latitude", required = false) BigDecimal latitude,  @RequestParam(value = "longitude", required = false) BigDecimal longitude)
    {
        return onlineMusicService.upload(file,musicName,latitude,longitude);
    }
    @ApiOperation("音乐播放")
    @GetMapping("/mp3{id}")
    public ResponseEntity<?> uploada(@PathVariable("id") String id )
    {
        return onlineMusicService.bofang(id);
    }

    @ApiOperation("音乐展示")
    @PostMapping("/show")
    public R show(OnlineMusic onlineMusic)
    {
        return onlineMusicService.show(onlineMusic);
    }


}
